'''
Description: 
Author: 天涯过客
Date: 2025-05-19 22:15:06
'''
#测试语义
import sys
sys.path.append("D:\\workbench\\py\\compile\\src")
from lexer import run_lexer
from parser import run_parser
from Semantic import run_semantic_analysis

def test_semantic():
    # 测试代码
    code = """
    int main() {
        int a;
        a = 5;
        return a;
    }
    """
    # 运行词法分析器
    tokens = run_lexer(code)
    print("Tokens:", tokens)

    # 运行语法分析器
    ast = run_parser(tokens)
    print("AST:", ast)

    # 运行语义分析器
    semantic,errors = run_semantic_analysis(ast)
    print("Semantic:", semantic)
    print("Errors:", errors)